﻿using Storage.DbEntities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage.Repositories
{
	public class ExerciseLogRep : Base.BaseRep<ExerciseLogDbEntity>
	{
		public ExerciseLogRep(SQLite.SQLiteAsyncConnection connection) : base(connection) { }

		public async Task<List<ExerciseLogDbEntity>> GetByExerciseId(Guid exerciseId)
		{
            var sqlSelectCommand = String.Format("Select * From {0} where FK_ExerciseId = '{1}'", TableName, exerciseId);
            return await _connection.QueryAsync<ExerciseLogDbEntity>(sqlSelectCommand);
		}

        public async Task<List<ExerciseLogDbEntity>> GetByExerciseIds(IEnumerable<Guid> exerciseIds)
        {
            var sqlSelectCommand = String.Format("Select * From {0} where FK_ExerciseId in ({1})", TableName, String.Join(",", exerciseIds.Select(x => String.Format("'{0}'", x))));
            var res = await _connection.QueryAsync<ExerciseLogDbEntity>(sqlSelectCommand);
            return res;
        }
	}
}
